/*个人资产分类备份
RequestGTMC("listConfCategoryByUserId", {},
function(json) {
    console.log("资产分类 获取成功");
    console.log(json);
    if (json && json.length > 0) {
         * val sub 为两次循环的索引值
         * arr 分组字符串切割后的数组
         * str 累加的字符串
         * sum 总资产计数器
        var val, sub, arr, str = '', sum = 0;
        // 表格数据操作
        for (val = 0; val < json.length; val++) {
            // 切割三层分类
            arr = json[val].conf_category_name.split(" ");
            if (arr.length < 4) {
                console.log("数据错误：" + json[val].conf_category_name);
                break;
            }
            arr[1] = arr[1].split("/")[0];
            arr[2]= arr[2].split("/")[0];
            arr[3]= arr[3].split("/")[0];
            str += '<li data-assets="' + (val < 10? '0' + (val+1) : (val+1)) + '"><a href="javascript:"><img src="' + (json[val].icon ? json[val].icon : '../images/my_assets_bg01.jpg') + '"></a><div class="picTitle"><span><b>' + arr[1];
            // 对象操作
            if (!ID_ARRAY.hasOwnProperty(arr[1])) {
                ID_ARRAY[arr[1]] = new Array();
                ID_ARRAY[arr[1]][0] = new Object();
                ID_ARRAY[arr[1]][0][arr[2]] = new Array();
                ID_ARRAY[arr[1]][0][arr[2]][0] = new Object();
                ID_ARRAY[arr[1]][0][arr[2]][0][arr[3]] = json[val].conf_category_id;
            } else {
                if (!ID_ARRAY[arr[1]][0].hasOwnProperty(arr[2])) {
                    ID_ARRAY[arr[1]][0][arr[2]] = new Array();
                    ID_ARRAY[arr[1]][0][arr[2]][0] = new Object();
                    ID_ARRAY[arr[1]][0][arr[2]][0][arr[3]] = json[val].conf_category_id;
                } else {
                    if (!ID_ARRAY[arr[1]][0][arr[2]][0].hasOwnProperty(arr[3])) {
                            ID_ARRAY[arr[1]][0][arr[2]][0][arr[3]] = json[val].conf_category_id;
                    } else {
                            ID_ARRAY[arr[1]][0][arr[2]][0][arr[3]] = json[val].conf_category_id;
                    }
                }
            }
            // 拼接后面数据
            arr[0] = arr[1] = "";
            arr = arr.join(" ");
            str +='</b><br /><i>' + arr + '</i></span></div><div class="picDetail"><span>硬件资源</span><span class="num">数量<i>' + json[val].count + '</i></span><a href="javascript:">查看详情&ensp;>></a></div></li>';
            // 填充总数变量
            sum += json[val].count;
        }
        $("#myself_assests_list .assetsList").html(str);
        /// 表头数据操作
        $(".mAssets_alltproject .mAssets_top .num").html(sum)
        str = '<a class="on" href="javascript:">全部资产<i>(' + sum + ')</i></a>';
        sub = 1;
        arr = {fir:"", sec:"", thi:""};
        console.log(ID_ARRAY);
        for (val in ID_ARRAY) {
            sum = 0;
            // 复用计数变量和发出请求
            for (arr.fir in ID_ARRAY[val][0]) {
                for (arr.sec in ID_ARRAY[val][0][arr.fir][0]) {
                    // 操作全部资产
                    arr.thi = ID_ARRAY[val][0][arr.fir][0][arr.sec];
                    ID_ARRAY[val][0][arr.fir][0][arr.sec] = new Array();
                    GetConfById(arr.thi, val, arr.fir, arr.sec);
                    sum++;
                }
            }
            str += '<a data-assets="' + (sub < 10 ? '0' + sub : sub) + '" href="javascript:">' + val + '<i>(' + sum + ')</i></a>';
            sub++
        }
        $("#myself_assests_list .myAssets_titleList .left").html(str);
    }
    AddDoneCount();
},
function() {
    console.log("资产分类 调用失败");
},
function() {
    console.log("资产分类 请求完成");
});
 提交搜索获取数据备份
 string:key 关键词
 int:pag 页码
 function QueryAssetInfo (key, pag) {
    // 个人资产搜索
    RequestGTMC("listUserConfByName", {
        name: key,
        page: pag,
        row: 8
    },
    function(json) {
        console.log("资产搜索 获取成功");
        console.log(json);
        if (json.content && json.content.length > 0) {
            /
              val 为两次循环的索引值
              arr 分组字符串切割后的数组
              str 累加的字符串
              sum 总资产计数器
             /
            var val, arr, str = '', sum = 0;
            // 表格数据操作
            for (val = 0; val < json.content.length; val++) {
                // 切割三层分类
                arr = json.content[val].conf_category_name.split(" ");
                if (arr.length < 4) {
                    console.log("数据错误：" + json.content[val].conf_category_name, arr);
                } else {
                    arr[1] = arr[1].split("/")[0];
                    arr[2]= arr[2].split("/")[0];
                    arr[3]= arr[3].split("/")[0];
                }
                str += '<li><a href="javascript:"><img src="' + (json.content[val].icon ? json.content[val].icon : '../images/my_assets_bg01.jpg') + '"></a><div class="picTitle"><span><b>' + arr[1];
                // 拼接后面数据
                arr[0] = arr[1] = "";
                arr = arr.join(" ");
                str +='</b><br /><i>' + arr + '</i></span></div><div class="picDetail"><span>硬件资源</span><span class="num">数量<i>' + (json.content[val].count?json.content[val].count:'') + '</i></span><a href="javascript:">查看详情&ensp;>></a></div></li>';
            }
            $("#myself_assests_list .assetsList").html(str);
            $(".common_shadow").removeClass('activate');
            $('.mAssets_search').removeClass('on');
            $('.mAssets_partproject').removeClass('on');
            $('.mAssets_alltproject').removeClass('on');
        }
    },
    function() {
        console.log("资产搜索 调用失败");
    },
    function() {
        console.log("资产搜索 请求完成");
    });
}*/

// 全局变量用以存储全部分类数据
var ID_ARRAY = new Array();
var USER_ARRAY = new Array();

/*
 * 获取单个资产列表
 * string:id 资产标识
 * string:i1 第一下标
 * string:i2 第二下标
 * string:i3 第三下标
 */
 function GetConfById (id, i1, i2, i3) {
    RequestGTMC("listUserConfByConfCategoryId", {
        confCategoryId: id
    },
    function(json) {
        if (json.content && json.content.length > 0) {
            // console.log(json, json.records);
            // 有多条数据统一合并成一项并显示数量
            ID_ARRAY[i1][0][i2][0][i3].push([json.content[0].code, json.records, json.content[0].duty_man_name, json.content[0].use_staff_name, json.content[0].maintainer_end_date, json.content[0].are_feedback, json.content[0].id]);
        }
    });
}

/*
 * 获取单个资产列表
 * string:id 资产标识
 * string:i1 第一下标
 * string:i2 第二下标
 */
 function GetConfLV2 (id, i1, i2) {
    RequestGTMC("listUserConfByConfCategoryId", {
        confCategoryId: id
    },
    function(json) {
        if (json.content && json.content.length > 0) {
            // 输出全部项目
            console.log("单个资产列表", json, json.records);
            for (var i = 0; i < json.content.length; i++) {
                USER_ARRAY[i1][0][i2].push([json.content[i].code, json.content[i].duty_man_name, json.content[i].use_staff_name, json.content[i].status, json.content[i].maintainer_end_date, json.content[i].are_feedback, json.content[i].id]);
                AddDetail();
            }
        }
    });
}

// 单个详情表格计数
function CalculateData() {
    var total = -1,
        nonce = 0;
    ClearDetail = function () {
        nonce = 0;
        total = -1;
        USER_ARRAY = new Array();
    };
    SetDetail = function (row) {
        if (parseInt(row) && row > 0) {
            total = row;
        }
    };
    AddDetail = function (num) {
        if (total !== -1 && ++nonce === total) {
            console.log("计数完成", "nonce", nonce, "total", total);
            CreateAssetTable();
        }
    };
}
var presondetail = CalculateData();

// 生成详情表格
function CreateAssetTable () {
    /*
         * fir sec thi 三维数组的下标
         * dou tre 计算是否与前面重叠
         * odd 累计的大行数
         * str 累加的字符串
         */
        var fir, sec, thi, dou, tre = 0, odd = 1,
            str = '<tr class="firstRow hide"><th class="name">名称</th><th class="num">编号</th><th class="duty">责任人</th><th class="user">使用人</th><th class="status">状态</th><th class="deadline">使用期限</th><th class="operation">操作</th></tr>';
        console.log("CreateAssetTable", USER_ARRAY);
        for (fir in USER_ARRAY) {
            dou = 0;
            for (sec in USER_ARRAY[fir][0]) {
                for (thi in USER_ARRAY[fir][0][sec]) {
                // 判断奇偶行
                    if (odd % 2 === 0) {
                        str += '<tr class="even">';
                    } else {
                        str += '<tr>';
                    }
                    //(dou > 0 ? '' : fir)
                    str += '<td class="firstColum">' + sec + '</td>';
                    str += '<td>' + (USER_ARRAY[fir][0][sec][thi][0] || '') + '</td><td>' + (USER_ARRAY[fir][0][sec][thi][1] || '') + '</td><td>' + (USER_ARRAY[fir][0][sec][thi][2] || '') + '</td><td>' + (USER_ARRAY[fir][0][sec][thi][3] || '') + '</td><td>' + (USER_ARRAY[fir][0][sec][thi][4] || '') + '</td>';
                        // 错误反馈
                        if (USER_ARRAY[fir][0][sec][thi][5] == 1) {
                            str += '<td class="lastTd"><div><a href="javascript:"><input class="wrong" type="button" value="错误反馈" /><input class="wrongON" type="button" value="错误反馈" /><input class="feedBack" type="button" value="待反馈跟进" /><input class="feedOk on" type="button" value="已反馈" /></a><span class="prop"><span class="reason">理由：</span><textarea class="txtBox"></textarea><span class="absolute"><i class="red">&lowast;&ensp;</i>必填</span><input class="submit" type="button" value="提交" /></span></div></td></tr>';
                        } else {
                            str += '<td class="lastTd" data-id="' + USER_ARRAY[fir][0][sec][thi][6] + '"><div><a href="javascript:"><input class="wrong on" type="button" value="错误反馈" /><input class="wrongON" type="button" value="错误反馈" /><input class="feedBack" type="button" value="待反馈跟进" /><input class="feedOk" type="button" value="已反馈" /></a><span class="prop"><span class="reason">理由：</span><textarea class="txtBox"></textarea><span class="absolute"><i class="red">&lowast;&ensp;</i>必填</span><input class="submit" type="button" value="提交" /></span></div></td></tr>';
                        }
                    tre++;
                    dou++;
                }
            }
            odd++;
        }
        $(".mAssets_partproject .right .num").html(tre);
        $('#myself_assests_one').html(str);
        // 绑定表格按钮
        $('.mAssets_partproject .lastTd .wrong').off('click').on('click', function() {
            var oLast = $(this).parents("tbody");
            oLast.find('.prop').removeClass('on');
            if (oLast.find('a').children('.on').is('.wrongON')) {
                oLast.find('a').children('.wrongON').removeClass('on').siblings('.wrong').addClass('on');
            }
            $(this).siblings('.wrongON').addClass('on').siblings('input').removeClass('on');
            $(this).parent().siblings('.prop').addClass('on');
        });
        // 绑定表格按钮
        $('.mAssets_partproject .lastTd .wrongON').off('click').on('click', function() {
            $(this).removeClass('on').siblings('.wrong').addClass('on');
            $(this).parent().siblings('.prop').removeClass('on');
        });
        $(".mAssets_partproject .lastTd .submit").off('click').on('click', function(event) {
            var txt = $(this).parent().children('textarea');
            console.log(txt.val(), $(this).parents('.lastTd').attr('data-id'));
            // 错误反馈
            RequestGTMC("listErrorFeedback", {
                confId : $(this).parents('.lastTd').attr('data-id'),
                reason : txt.val()
            }, function (json) {
                console.log("错误反馈 提交成功");
                console.log(json);
            });
            txt.val("");
            $(this).parent().removeClass('on').siblings('a').children('.feedBack').addClass('on').siblings('input').removeClass('on');
        });
        // 清空前面数据
        USER_ARRAY = new Array();
}

// 生成个人资产表格
function GetAssetTable (id) {
        // 打开弹框
        $('.mAssets_partproject').addClass('on').find('span.num').empty();
        $('.common_shadow').addClass('activate');
        $('#myself_assests_one').html('<div class="common_load" style="background-color:transparent;"><img src="../images/loading.gif"></div>');
    RequestGTMC("listThirdByFirstCategory", {
        categoryId: id
    },
    function(json) {
        console.log("单项表格 获取成功");
        console.log(id, json);
        if (json.content && json.content.length > 0) {
            var sum = 0;
            ClearDetail();
            for (var sub = 0; sub < json.content.length; sub++) {
                // 切割两层分类
                console.log(json.content[sub].count);
                sum += json.content[sub].count;
                SetDetail(sum);
                arr = json.content[sub].conf_category_name.split(" ");
                if (arr.length < 4) {
                    console.log("数据错误：" + json.content[sub].conf_category_name);
                    break;
                }
                arr[1] = arr[1].split("/")[0];
                arr[2] = arr[2].split("/")[0];
                arr[3] = arr[3].split("/")[0];
                if (!USER_ARRAY.hasOwnProperty(arr[2])) {
                    USER_ARRAY[arr[2]] = new Array();
                    USER_ARRAY[arr[2]][0] = new Object();
                    USER_ARRAY[arr[2]][0][arr[3]] = new Array();
                    // GetConfLV2(json.content[sub].conf_category_id, arr[2], arr[3]);
                } else {
                    USER_ARRAY[arr[2]][0][arr[3]] = new Array();
                    // GetConfLV2(json.content[sub].conf_category_id, arr[2], arr[3]);
                }
                GetConfLV2(json.content[sub].conf_category_id, arr[2], arr[3]);
            }
            console.log("USER_ARRAY", USER_ARRAY);
            // CreateAssetTable();
        }
    });
}

/*
 * 提交搜索获取数据
 * string:key 关键词
 * int:pag 页码
 */
 function QueryAssetInfo (key, pag) {
    $('.mAssets_search').removeClass('on');
    $('.asset_search_load').addClass('activate');
    // 个人资产搜索
    RequestGTMC("listUserConfByName", {
        name: key,
        page: pag
    },
    function(json) {
        console.log("资产搜索 获取成功");
        console.log(json);
        if (json.content && json.content.length > 0) {
            /*
             * val 为两次循环的索引值
             * arr 分组字符串切割后的数组
             * str 累加的字符串
             * sum 总资产计数器
             */
            var val, arr, str = '', sum = 0;
            // 表格数据操作
            ClearDetail();
            for (var sub = 0; sub < json.content.length; sub++) {
                // 切割两层分类
                console.log(json.content[sub]);
                sum += json.content[sub].count;
                SetDetail(sum);
                arr = json.content[sub].conf_category_name.split(" ");
                if (arr.length < 4) {
                    console.log("数据错误：" + json.content[sub].conf_category_name);
                    break;
                }
                arr[1] = arr[1].split("/")[0];
                arr[2] = arr[2].split("/")[0];
                arr[3] = arr[3].split("/")[0];
                if (!USER_ARRAY.hasOwnProperty(arr[2])) {
                    USER_ARRAY[arr[2]] = new Array();
                    USER_ARRAY[arr[2]][0] = new Object();
                    USER_ARRAY[arr[2]][0][arr[3]] = new Array();
                } else {
                    USER_ARRAY[arr[2]][0][arr[3]] = new Array();
                }
                // GetConfLV2(json.content[sub].conf_category_id, arr[2], arr[3]);
                USER_ARRAY[arr[2]][0][arr[3]].push([json.content[sub].code, json.content[sub].duty_man_name, json.content[sub].use_staff_name, json.content[sub].status, json.content[sub].masubntainer_end_date]);
            }
            console.log("USER_ARRAY", USER_ARRAY);
            /*$('.mAssets_partproject').removeClass('on');
            $(".common_shadow").removeClass('activate');
            $('.mAssets_alltproject').removeClass('on');
        $('#myself_assests_one').html('<div class="common_load" style="background-color:transparent;"><img src="../images/loading.gif"></div>');*/
            $('.asset_search_load').removeClass('activate');
        $('.mAssets_partproject').addClass('on');
        CreateAssetTable();
        } else {
            $('.asset_search_load').removeClass('activate');
            $('.asset_popup_report').addClass('activate');
        }
    },
    function() {
        console.log("资产搜索 调用失败");
    },
    function() {
        console.log("资产搜索 请求完成");
    });
}

// 个人资产分类获取
function QueryAllCategory (thispage) {
    RequestGTMC("listConfCategoryByUserId", {
        page:thispage || 1,
        row:8
    },
    function(json) {
        console.log("首屏资产 获取成功");
        console.log(json);
        if (json.content && json.content.length > 0) {
            /*
             * val 为两次循环的索引值
             * arr 分组字符串切割后的数组
             * str 累加的字符串
             */
            var val, arr, str = '';
            // 表格数据操作
            for (val = 0; val < json.content.length; val++) {
                // 切割三层分类
                arr = json.content[val].conf_category_name.split(" ");
                if (arr.length < 4) {
                    console.log("数据错误：" + json.content[val].conf_category_name, arr);
                } else {
                    arr[1] = arr[1].split("/")[0];
                    arr[2]= arr[2].split("/")[0];
                    arr[3]= arr[3].split("/")[0];
                }
                str += '<li><a href="javascript:"><img src="' + (json.content[val].icon ? ITSMLINK + json.content[val].icon : '../images/my_assets_bg01.jpg') + '"></a><div class="picTitle"><span><b>' + arr[1];
                // 拼接后面数据
                arr[0] = arr[1] = "";
                arr = arr.join(" ");
                str +='</b><br /><i>' + arr + '</i></span></div><div class="picDetail"><span class="num">数量<i>' + json.content[val].count + '</i></span><a href="javascript:" data-id="' + json.content[val].conf_category_id + '">查看详情&ensp;>></a></div></li>';
                // conf_category_id 究竟用哪个id？
            }
            $("#myself_assests_list .assetsList").html(str);
            $(".assetsList .picDetail a").off('click').on('click', function(event) {
                GetAssetTable($(this).attr('data-id'));
                $(".mAssets_partproject .left h3").html($(this).parent().siblings('.picTitle').find('b').html());
                $(".mAssets_partproject .left h6").html($(this).parent().siblings('.picTitle').find('i').html());
            });
            // 生成页码按钮
            if (parseInt(json.total) > 1) {
                console.log(json.total, parseInt(json.total) > 1);
                str = "";
                for (var i = 1; i <= json.total; i++) {
                    if (json.page === i) {
                        str += '<a href="javascript:" class="on">' + i + '</a>';
                    } else {
                        // 如果数据过多就显示一至三，总页数前三，当前页数前后两页，共九页
                        if (i < 4 || i > json.total - 3 || (i < json.page + 2 && i > json.page - 2)) {
                            str += '<a href="javascript:">' + i + '</a>';
                        } else if (i === json.page - 3 || i === json.page + 3) {
                            str += '<a href="javascript:" class="none">...</a>';
                        }
                    }
                }
                $("#common_list_pagination").show().children('.pages').html(str);
                $("#common_list_pagination .pages a").off('click').on('click', function(event) {
                    var pages = $(this).html().trim();
                    if (pages !== "...") {
                        console.log("jump to: " + pages);
                        $("#myself_assests_list .myAssets_titleList").before('<div class="common_load"><img src="../images/loading.gif"></div>');
                        QueryAllCategory(pages);
                    }
                });
                // 分页跳转按钮
                $("#common_list_pagination button").off('click').on('click', function(event) {
                    var pages = $(this).siblings('label').children('input').val();
                    if (pages !== "..." && parseInt(pages)) {
                        console.log("jump to: " + pages);
                        $("#myself_assests_list .myAssets_titleList").before('<div class="common_load"><img src="../images/loading.gif"></div>');
                        QueryAllCategory(pages);
                    }
                });
            } else {
                $("#common_list_pagination").removeAttr('style');
            }
        } else {
            $("#myself_assests_list .assetsList").html('<div class="common_none detail">暂无任何相关资产</div>');
            $("#myself_assests_list .myAssets_titleList .right").remove();
        }
        AddDoneCount();
    },
    function() {
        console.log("首屏资产 调用失败");
    },
    function() {
        console.log("首屏资产 请求完成");
    });
}

// 个人三级资产分类获取
function QueryTheCategory (thispage, thisid) {
    RequestGTMC("listThirdByFirstCategory", {
        categoryId:thisid,
        page:thispage || 1,
        row:8
    },
    function(json) {
        console.log("三级分类 获取成功");
        console.log(json);
        if (json.content && json.content.length > 0) {
            /*
             * val 为两次循环的索引值
             * arr 分组字符串切割后的数组
             * str 累加的字符串
             */
            var val, arr, str = '';
            // 表格数据操作
            for (val = 0; val < json.content.length; val++) {
                // 切割三层分类
                arr = json.content[val].conf_category_name.split(" ");
                if (arr.length < 4) {
                    console.log("数据错误：" + json.content[val].conf_category_name, arr);
                } else {
                    arr[1] = arr[1].split("/")[0];
                    arr[2]= arr[2].split("/")[0];
                    arr[3]= arr[3].split("/")[0];
                }
                str += '<li><a href="javascript:"><img src="' + (json.content[val].icon ? ITSMLINK + json.content[val].icon : '../images/my_assets_bg01.jpg') + '"></a><div class="picTitle"><span><b>' + arr[1];
                // 拼接后面数据
                arr[0] = arr[1] = "";
                arr = arr.join(" ");
                str +='</b><br /><i>' + arr + '</i></span></div><div class="picDetail"><span class="num">数量<i>' + json.content[val].count + '</i></span><a href="javascript:" data-id="' + json.content[val].conf_category_id + '">查看详情&ensp;>></a></div></li>';
            }
            $("#myself_assests_list .assetsList").html(str);
            $(".assetsList .picDetail a").off('click').on('click', function(event) {
                GetAssetTable($(this).attr('data-id'));
                $(".mAssets_partproject .left h3").html($(this).parent().siblings('.picTitle').find('b').html());
                $(".mAssets_partproject .left h6").html($(this).parent().siblings('.picTitle').find('i').html());
                //var timer = setTimeout(function(){CreateAssetTable();}, 1000);
            });
            // 生成页码按钮
            if (parseInt(json.total) > 1) {
                console.log(json.total, parseInt(json.total) > 1);
                str = "";
                for (var i = 1; i <= json.total; i++) {
                    if (json.page === i) {
                        str += '<a href="javascript:" class="on">' + i + '</a>';
                    } else {
                        // 如果数据过多就显示一至三，总页数前三，当前页数前后两页，共九页
                        if (i < 4 || i > json.total - 3 || (i < json.page + 2 && i > json.page - 2)) {
                            str += '<a href="javascript:">' + i + '</a>';
                        } else if (i === json.page - 3 || i === json.page + 3) {
                            str += '<a href="javascript:" class="none">...</a>';
                        }
                    }
                }
                $("#common_list_pagination").show().children('.pages').html(str);
                $("#common_list_pagination .pages a").off('click').on('click', function(event) {
                    var pages = $(this).html().trim();
                    if (pages !== "...") {
                        console.log("jump to: " + pages);
                        $("#myself_assests_list .myAssets_titleList").before('<div class="common_load"><img src="../images/loading.gif"></div>');
                        QueryAllCategory(pages);
                    }
                });
                // 分页跳转按钮
                $("#common_list_pagination button").off('click').on('click', function(event) {
                    var pages = $(this).siblings('label').children('input').val();
                    if (pages !== "...") {
                        console.log("jump to: " + pages);
                        $("#myself_assests_list .myAssets_titleList").before('<div class="common_load"><img src="../images/loading.gif"></div>');
                        QueryAllCategory(pages);
                    }
                });
            } else {
                $("#common_list_pagination").removeAttr('style');
            }
        }
        AddDoneCount();
    },
    function() {
        console.log("三级分类 调用失败");
    },
    function() {
        console.log("三级分类 请求完成");
    });
}

// 调用数据接口
+function() {
    var CommonSucceed = AjaxComplete(2);
    CommonBarNotify();
    QueryAllCategory(1);
    // 个人一级资产分类获取
    RequestGTMC("listFirstCategoryByUserId", {},
        function(json) {
            console.log("一级分类 获取成功");
            console.log(json);
            if (json && json.length > 0) {
                /*
                 * val sub 为两次循环的索引值
                 * arr 分组字符串切割后的数组
                 * str 累加的字符串
                 * sum 总资产计数器
                 */
                var val, sub, arr, str = '', sum = 0;
                // 表格数据操作
                for (val = 0; val < json.length; val++) {
                    // 切割三层分类
                    arr = json[val].name.split(" ");
                    if (arr.length > 1) {
                        str += '<a data-id="' + json[val].id + '" href="javascript:">' + arr[1] + '<i>(' + json[val].count + ')</i></a>';
                    } else {
                        console.log("全部资产：" + json[val].count);
                        str = '<a class="on" href="javascript:">' + arr[0] + '<i>(' + json[val].count + ')</i></a>' + str;
                        $(".mAssets_alltproject .right .num").html(json[val].count);
                    }
                    /*str += '<li data-assets="' + (val < 10 ? '0' + (val + 1) : (val + 1)) + '"><a href="javascript:"><img src="' + (json[val].icon ? json[val].icon : '../images/my_assets_bg01.jpg') + '"></a><div class="picTitle"><span><b>' + arr[1];*/
                    // 对象操作
                    /*if (!ID_ARRAY.hasOwnProperty(arr[1])) {
                        ID_ARRAY[arr[1]] = new Array();
                        ID_ARRAY[arr[1]][0] = new Object();
                        ID_ARRAY[arr[1]][0][arr[2]] = new Array();
                        ID_ARRAY[arr[1]][0][arr[2]][0] = new Object();
                        ID_ARRAY[arr[1]][0][arr[2]][0][arr[3]] = json[val].conf_category_id;
                    } else {
                        if (!ID_ARRAY[arr[1]][0].hasOwnProperty(arr[2])) {
                            ID_ARRAY[arr[1]][0][arr[2]] = new Array();
                            ID_ARRAY[arr[1]][0][arr[2]][0] = new Object();
                            ID_ARRAY[arr[1]][0][arr[2]][0][arr[3]] = json[val].conf_category_id;
                        } else {
                            if (!ID_ARRAY[arr[1]][0][arr[2]][0].hasOwnProperty(arr[3])) {
                                ID_ARRAY[arr[1]][0][arr[2]][0][arr[3]] = json[val].conf_category_id;
                            } else {
                                ID_ARRAY[arr[1]][0][arr[2]][0][arr[3]] = json[val].conf_category_id;
                            }
                        }
                    }*/
                    // 拼接后面数据
                    /*arr[0] = arr[1] = "";
                    arr = arr.join(" ");
                    str += '</b><br /><i>' + arr + '</i></span></div><div class="picDetail"><span>硬件资源</span><span class="num">数量<i>' + json[val].count + '</i></span><a href="javascript:">查看详情&ensp;>></a></div></li>';*/
                    // 填充总数变量
                    // sum += json[val].count;
                }
                $("#myself_assests_list .myAssets_titleList .left").html(str);
                $("#myself_assests_list .myAssets_titleList .left").on('click', 'a', function(event) {
                    $("#myself_assests_list .myAssets_titleList").before('<div class="common_load"><img src="../images/loading.gif"></div>');
                    $(this).addClass('on').siblings('a').removeClass('on');
                    if ($(this).attr('data-id') !== undefined) {
                        console.log("id", $(this).attr('data-id'));
                        QueryTheCategory(1, $(this).attr('data-id'));
                    } else {
                        QueryAllCategory(1);
                    }
                });
                /*$("#myself_assests_list .myAssets_titleList .left").on('click', 'a:not([data-id])', function(event) {
                    $("#myself_assests_list .myAssets_titleList").before('<div class="common_load"><img src="../images/loading.gif"></div>');
                    QueryAllCategory(1);
                });*/
                // 表头数据操作
                /*$(".mAssets_alltproject .mAssets_top .num").html(sum)
                str = '<a class="on" href="javascript:">全部资产<i>(' + sum + ')</i></a>';
                sub = 1;
                arr = {
                    fir: "",
                    sec: "",
                    thi: ""
                };
                console.log(ID_ARRAY);
                for (val in ID_ARRAY) {
                    sum = 0;
                    // 复用计数变量和发出请求
                    for (arr.fir in ID_ARRAY[val][0]) {
                        for (arr.sec in ID_ARRAY[val][0][arr.fir][0]) {
                            // 操作全部资产
                            arr.thi = ID_ARRAY[val][0][arr.fir][0][arr.sec];
                            ID_ARRAY[val][0][arr.fir][0][arr.sec] = new Array();
                            GetConfById(arr.thi, val, arr.fir, arr.sec);
                            sum++;
                        }
                    }
                    str += '<a data-assets="' + (sub < 10 ? '0' + sub : sub) + '" href="javascript:">' + val + '<i>(' + sum + ')</i></a>';
                    sub++
                }*/
            } else {
                $("#myself_assests_list .myAssets_titleList .left").empty();
            }
            AddDoneCount();
        },
        function() {
            console.log("一级分类 调用失败");
        },
        function() {
            console.log("一级分类 请求完成");
        });
    //所有分类
    /*RequestGTMC("listConfCategoryByUserId", {},
        function(json) {
            console.log("所有分类 获取成功");
            console.log(json);
            if (json && json.content.length > 0) {
                /
                 * val sub 为两次循环的索引值
                 * arr 分组字符串切割后的数组
                 * str 累加的字符串
                 * sum 总资产计数器
                 /
                var val, sub, arr, str = '',
                    sum = 0;
                // 表格数据操作
                for (val = 0; val < json.content.length; val++) {
                    // 切割三层分类
                    arr = json.content[val].conf_category_name.split(" ");
                    if (arr.length < 4) {
                        console.log("数据错误：" + json.content[val].conf_category_name);
                        break;
                    }
                    arr[1] = arr[1].split("/")[0];
                    arr[2] = arr[2].split("/")[0];
                    arr[3] = arr[3].split("/")[0];
                    if (!ID_ARRAY.hasOwnProperty(arr[1])) {
                        ID_ARRAY[arr[1]] = new Array();
                        ID_ARRAY[arr[1]][0] = new Object();
                        ID_ARRAY[arr[1]][0][arr[2]] = new Array();
                        ID_ARRAY[arr[1]][0][arr[2]][0] = new Object();
                        ID_ARRAY[arr[1]][0][arr[2]][0][arr[3]] = json.content[val].conf_category_id;
                    } else {
                        if (!ID_ARRAY[arr[1]][0].hasOwnProperty(arr[2])) {
                            ID_ARRAY[arr[1]][0][arr[2]] = new Array();
                            ID_ARRAY[arr[1]][0][arr[2]][0] = new Object();
                            ID_ARRAY[arr[1]][0][arr[2]][0][arr[3]] = json.content[val].conf_category_id;
                        } else {
                            if (!ID_ARRAY[arr[1]][0][arr[2]][0].hasOwnProperty(arr[3])) {
                                ID_ARRAY[arr[1]][0][arr[2]][0][arr[3]] = json.content[val].conf_category_id;
                            } else {
                                ID_ARRAY[arr[1]][0][arr[2]][0][arr[3]] = json.content[val].conf_category_id;
                            }
                        }
                    }
                }
                sub = 1;
                arr = {
                    fir: "",
                    sec: "",
                    thi: ""
                };
                console.log("ID_ARRAY", ID_ARRAY);
                for (val in ID_ARRAY) {
                    sum = 0;
                    // 复用计数变量和发出请求
                    for (arr.fir in ID_ARRAY[val][0]) {
                        for (arr.sec in ID_ARRAY[val][0][arr.fir][0]) {
                            // 操作全部资产
                            arr.thi = ID_ARRAY[val][0][arr.fir][0][arr.sec];
                            ID_ARRAY[val][0][arr.fir][0][arr.sec] = new Array();
                            GetConfById(arr.thi, val, arr.fir, arr.sec);
                            sum++;
                        }
                    }
                    sub++
                }
            }
            AddDoneCount();
        },
        function() {
            console.log("所有分类 调用失败");
        },
        function() {
            console.log("所有分类 请求完成");
        });*/
    // 个人资产搜索
    RequestGTMC("listConfByUserId", {row : 100},
    function(json) {
        console.log("资产表格 获取成功");
        console.log(json);
        if (json.content && json.content.length > 0) {
            var sub, all = new Array(), arr, tie = json.content[json.content.length - 1]["countMap"];
            /*for (sub in tie) {
                arr = tie[sub]["conf_category_name"].split(" ");
                if (arr.length < 4) {
                    console.log("数据错误：" + tie[sub]["conf_category_name"]);
                    continue;
                }
                arr[1] = arr[1].split("/")[0];
                arr[2] = arr[2].split("/")[0];
                arr[3] = arr[3].split("/")[0];
                if (!all.hasOwnProperty(arr[1])) {
                    all[arr[1]] = new Array();
                    all[arr[1]][0] = new Object();
                    all[arr[1]][0][arr[2]] = new Array();
                    all[arr[1]][0][arr[2]][0] = new Object();
                    all[arr[1]][0][arr[2]][0][arr[3]] =  tie[sub]["count"];
                } else {
                    if (!all[arr[1]][0].hasOwnProperty(arr[2])) {
                        all[arr[1]][0][arr[2]] = new Array();
                        all[arr[1]][0][arr[2]][0] = new Object();
                        all[arr[1]][0][arr[2]][0][arr[3]] =  tie[sub]["count"];
                    } else {
                        if (!all[arr[1]][0][arr[2]][0].hasOwnProperty(arr[3])) {
                            all[arr[1]][0][arr[2]][0][arr[3]] =  tie[sub]["count"];
                        } else {
                            all[arr[1]][0][arr[2]][0][arr[3]] =  tie[sub]["count"];
                        }
                    }
                }
            }
            console.log("all", all);*/
            all = new Array();
            for (sub = 0; sub < json.content.length - 1; sub++) {
                arr = json.content[sub]["conf_category_name"].split(" ");
                if (arr.length < 4) {
                    console.log("数据错误：" + json.content[sub]["conf_category_name"]);
                    continue;
                }
                arr[1] = arr[1].split("/")[0];
                arr[2] = arr[2].split("/")[0];
                arr[3] = arr[3].split("/")[0];
                if (!all.hasOwnProperty(arr[1])) {
                    all[arr[1]] = new Array();
                    all[arr[1]][0] = new Object();
                    all[arr[1]][0][arr[2]] = new Array();
                    all[arr[1]][0][arr[2]][0] = new Object();
                    all[arr[1]][0][arr[2]][0][arr[3]] = new Array();
                    all[arr[1]][0][arr[2]][0][arr[3]].push([json.content[sub]["code"], json.records, json.content[sub]["duty_man_name"], json.content[sub]["use_staff_name"], json.content[sub]["maintainer_end_date"], json.content[sub]["are_feedback"], json.content[sub]["id"]]);
                } else {
                    if (!all[arr[1]][0].hasOwnProperty(arr[2])) {
                        all[arr[1]][0][arr[2]] = new Array();
                        all[arr[1]][0][arr[2]][0] = new Object();
                        all[arr[1]][0][arr[2]][0][arr[3]] = new Array();
                        all[arr[1]][0][arr[2]][0][arr[3]].push([json.content[sub]["code"], json.records, json.content[sub]["duty_man_name"], json.content[sub]["use_staff_name"], json.content[sub]["maintainer_end_date"], json.content[sub]["are_feedback"], json.content[sub]["id"]]);
                    } else {
                        if (!all[arr[1]][0][arr[2]][0].hasOwnProperty(arr[3])) {
                            all[arr[1]][0][arr[2]][0][arr[3]] = new Array();
                            all[arr[1]][0][arr[2]][0][arr[3]].push([json.content[sub]["code"], json.records, json.content[sub]["duty_man_name"], json.content[sub]["use_staff_name"], json.content[sub]["maintainer_end_date"], json.content[sub]["are_feedback"], json.content[sub]["id"]]);
                        } else {
                            all[arr[1]][0][arr[2]][0][arr[3]].push([json.content[sub]["code"], json.records, json.content[sub]["duty_man_name"], json.content[sub]["use_staff_name"], json.content[sub]["maintainer_end_date"], json.content[sub]["are_feedback"], json.content[sub]["id"]]);
                        }
                    }
                }
            }
            console.log("all", all);
            var fir, sec, thi, dou, tre, qua, odd = 1,
                str = '<tr class="firstRow hide"><th class="type">类别</th><th class="name">名称</th><th class="num">编号</th><th class="amount">数量</th><th class="duty">责任人</th><th class="user">使用人</th><th class="deadline">使用期限</th><th class="operation">操作</th></tr>';
            for (fir in all) {
                dou = 0;
                for (sec in all[fir][0]) {
                    tre = 0;
                    for (thi in all[fir][0][sec][0]) {
                        // 判断奇偶行
                        /*if (odd % 2 === 0) {
                            str += '<tr class="even">';
                        } else {
                            str += '<tr>';
                        }
                        str += '<td class="firstColum">' + (dou > 0 ? '' : fir) + '</td>';
                        str += '<td class="secondColum">' + (tre > 0 ? '' : sec) + '</td>';
                        str += '<td>' + thi + '</td><td class="greenColumn">' + all[fir][0][sec][0][thi].length + '</td><td>' + (all[fir][0][sec][0][thi][0][0] || '') + '</td><td>' + (all[fir][0][sec][0][thi][0][2] || '') + '</td><td>' + (all[fir][0][sec][0][thi][0][3] || '') + '</td><td>' + (all[fir][0][sec][0][thi][0][4] || '') + '</td>';
                            str += '<td class="lastTd"><div><a href="javascript:"><input class="wrong on" type="button" value="错误反馈" /><input class="wrongON" type="button" value="错误反馈" /><input class="feedBack" type="button" value="待反馈跟进" /><input class="feedOk" type="button" value="已反馈" /></a><span class="prop"><span class="reason">理由：</span><textarea class="txtBox"></textarea><span class="absolute"><i class="red">&lowast;&ensp;</i>必填</span><input class="submit" type="button" value="提交" /></span></div></td></tr>';*/
                        for (qua = 0; qua < all[fir][0][sec][0][thi].length; qua++) {
                            // 判断奇偶行
                            if (odd % 2 === 0) {
                                str += '<tr class="even">';
                            } else {
                                str += '<tr>';
                            }
                            str += '<td class="firstColum">' + fir + '</td><td>' + sec + '</td>';
                            str += '<td>' + thi + '</td><td>' + (all[fir][0][sec][0][thi][qua][0] || '') + '</td><td>' + (all[fir][0][sec][0][thi][qua][2] || '') + '</td><td>' + (all[fir][0][sec][0][thi][qua][3] || '') + '</td><td>' + (all[fir][0][sec][0][thi][qua][4] || '') + '</td>';
                            // 错误反馈
                            if (all[fir][0][sec][0][thi][qua][5] == 1) {
                                str += '<td class="lastTd"><div><a href="javascript:"><input class="wrong" type="button" value="错误反馈" /><input class="wrongON" type="button" value="错误反馈" /><input class="feedBack" type="button" value="待反馈跟进" /><input class="feedOk on" type="button" value="已反馈" /></a><span class="prop"><span class="reason">理由：</span><textarea class="txtBox"></textarea><span class="absolute"><i class="red">&lowast;&ensp;</i>必填</span><input class="submit" type="button" value="提交" /></span></div></td></tr>';
                            } else {
                                str += '<td class="lastTd" data-id="' + all[fir][0][sec][0][thi][qua][6] + '"><div><a href="javascript:"><input class="wrong on" type="button" value="错误反馈" /><input class="wrongON" type="button" value="错误反馈" /><input class="feedBack" type="button" value="待反馈跟进" /><input class="feedOk" type="button" value="已反馈" /></a><span class="prop"><span class="reason">理由：</span><textarea class="txtBox"></textarea><span class="absolute"><i class="red">&lowast;&ensp;</i>必填</span><input class="submit" type="button" value="提交" /></span></div></td></tr>';
                            }
                        }
                        tre++;
                        dou++;
                    }
                }
                odd++;
            }
            $('#myself_assests_all').html(str);
        // 绑定表格按钮
        $('.mAssets_alltproject .lastTd .wrong').off('click').on('click', function() {
            var oLast = $(this).parents("tbody");
            oLast.find('.prop').removeClass('on');
            if (oLast.find('a').children('.on').is('.wrongON')) {
                oLast.find('a').children('.wrongON').removeClass('on').siblings('.wrong').addClass('on');
            }
            $(this).siblings('.wrongON').addClass('on').siblings('input').removeClass('on');
            $(this).parent().siblings('.prop').addClass('on');
        });
        // 绑定表格按钮
        $('.mAssets_alltproject .lastTd .wrongON').off('click').on('click', function() {
            $(this).removeClass('on').siblings('.wrong').addClass('on');
            $(this).parent().siblings('.prop').removeClass('on');
        });
        $(".mAssets_alltproject .lastTd .submit").off('click').on('click', function(event) {
            var txt = $(this).parent().children('textarea');
            console.log(txt.val(), $(this).parents('.lastTd').attr('data-id'));
            // 错误反馈
            RequestGTMC("listErrorFeedback", {
                confId : $(this).parents('.lastTd').attr('data-id'),
                reason : txt.val()
            }, function (json) {
                console.log("错误反馈 提交成功");
                console.log(json);
            });
            txt.val("");
            $(this).parent().removeClass('on').siblings('a').children('.feedBack').addClass('on').siblings('input').removeClass('on');
        });
        }
    },
    function() {
        console.log("资产表格 调用失败");
    },
    function() {
        console.log("资产表格 请求完成");
    });
}();

// 事件绑定
-function() {
    // 分页前后按钮
    $("#common_list_pagination .history_btn_listl").on("click", function(event) {
        $(this).siblings('.pages').children('.on').prev("a").trigger('click');
    });
    $("#common_list_pagination .history_btn_listr").on("click", function(event) {
        $(this).siblings('.pages').children('.on').next("a").trigger('click');
    });
    // 点击全部资产列表
    $("#myself_assests_list .myAssets_titleList .right").on('click', '.allList', function(event) {
        /*
         * fir sec thi 三维数组的下标
         * dou tre 计算是否与前面重叠
         * odd 累计的大行数
         * str 累加的字符串
         */
        /*var fir, sec, thi, dou, tre, odd = 1,
            str = '<tr class="firstRow hide"><th class="type">类别</th><th class="name">名称</th><th class="num">编号</th><th class="amount">数量</th><th class="duty">责任人</th><th class="user">使用人</th><th class="deadline">使用期限</th><th class="operation">操作</th></tr>';
        for (fir in ID_ARRAY) {
            dou = 0;
            for (sec in ID_ARRAY[fir][0]) {
                tre = 0;
                for (thi in ID_ARRAY[fir][0][sec][0]) {
                    // 判断奇偶行
                    if (odd % 2 === 0) {
                        str += '<tr class="even">';
                    } else {
                        str += '<tr>';
                    }
                    str += '<td class="firstColum">' + (dou > 0 ? '' : fir) + '</td>';
                    str += '<td class="secondColum">' + (tre > 0 ? '' : sec) + '</td>';
                    str += '<td>' + (ID_ARRAY[fir][0][sec][0][thi][0][0] || '') + '</td><td class="greenColumn">' + (ID_ARRAY[fir][0][sec][0][thi][0][1] || '') + '</td><td>' + (ID_ARRAY[fir][0][sec][0][thi][0][2] || '') + '</td><td>' + (ID_ARRAY[fir][0][sec][0][thi][0][3] || '') + '</td><td>' + (ID_ARRAY[fir][0][sec][0][thi][0][4] || '') + '</td>';
                    // 错误反馈
                    str += '<td class="lastTd"><div><a href="javascript:"><input class="wrong on" type="button" value="错误反馈" /><input class="wrongON" type="button" value="错误反馈" /><input class="feedBack" type="button" value="待反馈跟进" /><input class="feedOk" type="button" value="已反馈" /></a><span class="prop"><span class="reason">理由：</span><textarea class="txtBox"></textarea><span class="absolute"><i class="red">&lowast;&ensp;</i>必填</span><input class="submit" type="button" value="提交" /></span></div></td></tr>';
                    tre++;
                    dou++;
                }
            }
            odd++;
        }
        $('#myself_assests_all').html(str);*/
        $('.mAssets_alltproject').addClass('on');
        $('.common_shadow').addClass('activate');
    });
    // 点击搜索
    $("#myself_assests_list .myAssets_titleList .right").on('click', '.search', function(event) {
        console.log("点击搜索？？？");
        $('.common_shadow').addClass('activate');
        $('.mAssets_search').addClass('on').children('.searchBox').val("").focus();
        $(".common_shadow .mAssets_search .searchBox").val("请输入关键词搜索，如类别，名称，编号。");
    });
    // 搜索提交
    $(".common_shadow .mAssets_search .labelBox").on('click', function(event) {
        QueryAssetInfo($(this).siblings('.searchBox').val(), 1);
        $(".mAssets_partproject .left h3").html("搜索结果");
        $(".mAssets_partproject .left h6").html("");
        //var timer = setTimeout(function(){CreateAssetTable();}, 1000);
    });
    $(".common_shadow .mAssets_search .searchBox").on('keydown', function(event) {
        var tmp = $(this).val().trim().indexOf("请输入关键词搜索，如类别，名称，编号。");
        if(tmp > -1) {
            $(this).val("");
        }
        if (event.keyCode === 13 && $(this).val().trim() !== "") {
            QueryAssetInfo($(this).val().trim(), 1);
            $(".mAssets_partproject .left h3").html("搜索结果");
            $(".mAssets_partproject .left h6").html("");
            //var timer = setTimeout(function(){CreateAssetTable();}, 1000);
        }
    });
    // myAssets 页面的 input 框
    // inputFn($('.mAssets_search>.searchBox'));
    $(".common_shadow .mAssets_search .searchBox").on('change', function(event) {
        var tmp = $(this).val().trim().indexOf("请输入关键词搜索，如类别，名称，编号。");
        if(tmp > -1) {
            $(this).val("");
        }
    });
    // 点击myAssets_titleList切换列表显示不同类型资源
    var oSource = $('.myAssets_titleList>.left>a');
    var oAssets = $('.assetsList>li');
    var oLiBtn = oAssets.children('.picDetail').children('a');
    var oTxt = oAssets.attr('data-assets');
    var mask = $('');
    oSource.click(function() {
            $(this).addClass('on');
            $(this).siblings('a').removeClass('on');
        });
    // 点击查看详情
    oLiBtn.click(function() {
        $('.mAssets_partproject').addClass('on');
        $('.common_shadow').addClass('activate');
        // lastFn('.mAssets_partproject');
    });
    // prop close 关闭弹框
    $('.common_shadow .close').click(handler2Fn);
    function handler2Fn(event) {
        var $target = $(event.target);
        var $parent = $target.parent().parent();
        if ($parent.is('.mAssets_alltproject')) {
            $('.mAssets_alltproject').removeClass('on');
        } else if ($parent.is('.mAssets_partproject')) {
            $('.mAssets_partproject').removeClass('on');
        };
        $('.common_shadow').removeClass('activate');
    }
    // 确认按钮
    $(".asset_popup_report .back a").on('click', function(event) {
        $('.asset_popup_report').removeClass('activate');
        $('.common_shadow').removeClass('activate')
    });
    // 点击灰色区域,隐藏弹框
    $('.common_shadow').click(function(event) {
        if ($(event.target).is(".common_shadow") && !$(".mAssets_cont").hasClass('on')) {
            $(this).removeClass('activate');
            $('.mAssets_search').removeClass('on');
            $('.mAssets_partproject').removeClass('on');
            $('.mAssets_alltproject').removeClass('on');
        }
    });
    // 隐藏所有 .lastTd 的prop 弹框
    /*function lastFn(obj) {
        var oLast = $(obj + ' .lastTd>div');
        // 点击wrong弹出  反馈prop 弹框；
        $('.mAssets_table a>.wrong').click(function() {
                for (var j = 0; j < oLast.length; j++) {
                    oLast.eq(j).children('.prop').removeClass('on');
                    if (oLast.eq(j).children('a').children('.on').is('.wrongON')) {
                        oLast.eq(j).children('a').children('.wrongON').removeClass('on').siblings('.wrong').addClass('on');
                    }
                }
                $(this).siblings('.wrongON').addClass('on').siblings('input').removeClass('on');
                $(this).parent().siblings('.prop').addClass('on');
            });
        // 点击自己弹框隐藏；
        $('.mAssets_table a>.wrongON').click(function() {
            $(this).removeClass('on').siblings('.wrong').addClass('on');
            $(this).parent().siblings('.prop').removeClass('on');
        });
    }*/
}();